<div data-am-widget="tabs" data-am-tabs="{noSwipe: 1}" class="am-tabs am-tabs-default">
    <ul class="am-tabs-nav am-cf">
        <li class="am-active"><a href="#">修改登录密码</a></li>
        <li class=""><a href="#">修改提款密码</a></li>
        <li class="xx"></li>
    </ul>
    <div class="am-tabs-bd withdrawal">
        <div data-tab-panel-0 class="am-tab-panel am-active">
            <div class="drawform p1">
                <div class="mypwd wrap"><div class="el-form" action="#">
                    <div class="el-form-item is-required">
                        <label for="currentPwd" class="el-form-item__label" style="width: 100px;">当前密码</label>
                        <div class="el-form-item__content" style="margin-left: 100px;">
                            <div class="el-input">
                                <input autocomplete="off" name="old" type="password" rows="2" validateevent="true" class="el-input__inner">
                            </div> 
                            <span>密码长度为6-12个字符字母组合</span>
                        </div>
                    </div> 
                    <div class="el-form-item is-required">
                        <label for="newPwd" class="el-form-item__label" style="width: 100px;">新密码</label>
                        <div class="el-form-item__content" style="margin-left: 100px;">
                            <div class="el-input">
                                <input autocomplete="off" name="p1" type="password" rows="2" validateevent="true" class="el-input__inner">
                            </div>
                        </div>
                    </div> 
                    <div class="el-form-item is-required">
                        <label for="confirmNewPwd" class="el-form-item__label" style="width: 100px;">确认新密码</label>
                        <div class="el-form-item__content" style="margin-left: 100px;">
                            <div class="el-input">
                                <input autocomplete="off" name="p2" type="password" rows="2" validateevent="true" class="el-input__inner">
                            </div>
                        </div>
                    </div> 
                    <div class="el-form-item">
                        <div class="el-form-item__content" style="margin-left: 100px;">
                            <button class="el-button el-button--warning el-button--small profile-button">
                                <span>提交</span>
                            </button>
                        </div>
                    </div>
                </div></div>
            </div>
        </div>
        <div data-tab-panel-1 class="am-tab-panel">
            <div class="drawform p2">
                <div class="mypwd wrap"><div class="el-form" action="#">
                    <div class="el-form-item is-required">
                        <label class="el-form-item__label" style="width: 120px;">当前提现密码</label>
                        <div class="el-form-item__content" style="margin-left: 120px;">
                            <div class="el-input">
                                <input autocomplete="off" name="old" type="password" rows="2" validateevent="true" class="el-input__inner">
                            </div> 
                        </div>
                    </div> 
                    <div class="el-form-item is-required">
                        <label for="newPwd" class="el-form-item__label" style="width: 120px;">新密码</label>
                        <div class="el-form-item__content" style="margin-left: 120px;">
                            <div class="el-input">
                                <input autocomplete="off" name="p1" type="password" rows="2" validateevent="true" class="el-input__inner">
                            </div>
                        </div>
                    </div> 
                    <div class="el-form-item is-required">
                        <label for="confirmNewPwd" class="el-form-item__label" style="width: 120px;">确认新密码</label>
                        <div class="el-form-item__content" style="margin-left: 120px;">
                            <div class="el-input">
                                <input autocomplete="off" name="p2" type="password" rows="2" validateevent="true" class="el-input__inner">
                            </div>
                        </div>
                    </div> 
                    <div class="el-form-item">
                        <div class="el-form-item__content" style="margin-left: 120px;">
                            <button class="el-button el-button--warning el-button--small profile-button">
                                <span>提交</span>
                            </button>
                        </div>
                    </div>
                </div></div>
            </div>
        </div>
    </div>
</div>

<script>
    $(".tabs").tabs();
    $(".p1 .profile-button").click(function() {
        // 修改登录密码
        var old = $(".p1 input[name='old']").val().trim();
        var p1 = $(".p1 input[name='p1']").val().trim();
        var p1 = $(".p1 input[name='p2']").val().trim();
        if (old == '') {
            alert2("请输入当前登录密码", true);
            return;
        }
        if (p1 == '') {
            alert2("请输入要设置的新的登录密码", true);
            return;
        }
        if (p1 != p2) {
            alert2("两次输入的密码不一致，请重新输入", true);
            return;
        }

        CMD.modify_password(p1, old, function() {
            alert2("修改登录密码成功");
        }, function(message) {
            alert2(message || '修改登录密码失败', true);
        });
    })

    $(".p2 .profile-button").click(function() {
        // 修改提款密码
        var old = $(".p2 input[name='old']").val().trim();
        var p1 = $(".p2 input[name='p1']").val().trim();
        var p1 = $(".p2 input[name='p2']").val().trim();
        if (!p1) {
            alert2("请输入新的提款密码", true);
            return;
        }
        var patrn= /^[0-9]{4}$/; 
		if (!patrn.exec(p1)){
			 alert2('请设置4位的数字的提款密码', true);
			return;
		}
        if (p1 != p2) {
            alert2('两次输入的密码不一致，请重新输入', true);
            return;
        }

        var old = $("#fundpwd").val().trim();
        if (context.user.user.tpassword != old && context.user.user.tpassword) {
            alert2("当前提款密码错误", true);
            return;
        }

        CMD.modify_user_info(undefined, {
            tpassword: p1,
        }, function() {
            alert2("修改提款密码成功");
        });
    })
</script>
